//========================
// Filename: draw.cpp
//========================
#include "draw.h"

Draw* Draw::GetSingleton() {
	static Draw instance;

	return &instance;
}

Draw::~Draw() {
}

void Draw::Color3f(float r, float g, float b) {
	m_Red = r;
	m_Green = g;
	m_Blue = b;
}

void Draw::DrawCircle(float X, float Y, float radius) {
	int i;
	double angle;
	double x,y;

	glBegin(GL_LINE_LOOP);
	glColor3d(m_Red, m_Green, m_Blue);

	for(i = 0; i <= 360; i++) {
		angle = i * PI / 180;
		x = X + radius * cos(angle);
		y = Y + radius * sin(angle);
		glVertex2d(x, y);
	}

	glEnd();
}

void Draw::DrawCircle(Vector2f center, float radius) {
	DrawCircle(center.X, center.Y, radius);
}

void Draw::DrawRectangle(float X1, float Y1, float X2, float Y2) {
	glBegin(GL_LINE_LOOP);
	glColor3d(m_Red, m_Green, m_Blue);

	glVertex2f(X1, Y1);
	glVertex2f(X1, Y2);
	glVertex2f(X2, Y2);
	glVertex2f(X2, Y1);

	glEnd();
}

void Draw::DrawRectangle(Vector2f p1, Vector2f p2) {
	DrawRectangle(p1.X, p1.Y, p2.X, p2.Y);
}

void Draw::DrawTriangle(float X1, float Y1, float X2, float Y2, float X3, float Y3) {
	glBegin(GL_LINE_LOOP);
	glColor3d(m_Red, m_Green, m_Blue);

	glVertex2f(X1, Y1);
	glVertex2f(X2, Y2);
	glVertex2f(X3, Y3);

	glEnd();
}

void Draw::DrawTriangle(Vector2f p1, Vector2f p2, Vector2f p3) {
	DrawTriangle(p1.X, p1.Y, p2.X, p2.Y, p3.X, p3.Y);
}